﻿using System;
using System.Globalization;

namespace Yawf.Core.Utils {
	public class DateUtils {

		/// <summary>
		/// Parses a string as a Date according a special format String
		/// </summary>
		/// <param name="formatStr">Format string that date is in</param>
		/// <param name="dateStr">String representing a Date</param>
		/// <returns>A DateTime structure representing the parse date</returns>
		public static DateTime ParseDate(String formatStr,String dateStr) {
			DateTime tmpDate;

			if (DateTime.TryParseExact(dateStr,formatStr,CultureInfo.InvariantCulture,DateTimeStyles.None,out tmpDate)) {
				return tmpDate;
			}
			return DateTime.MinValue;
		}
	}
}
